package cn.new7as.cas5s.anhjkfu;

import android.content.Context;
import android.view.View;
import android.widget.RatingBar;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.CenterPopupView;
import com.lxj.xpopup.util.XPopupUtils;

import cn.new7as.cas5s.R;
import cn.new7as.cas5s.tool.util.SharePreferenceUtils;
import cn.new7as.cas5s.tool.util.Utils;

public class StartPop extends CenterPopupView {

Context context;
    public StartPop(@NonNull Context context) {
        super(context);
        this.context=context;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.pop_star;
    }
private String rscore="4";
    @Override
    protected void onCreate() {
        super.onCreate();

        TextView extend = findViewById(R.id.extend);
        SharePreferenceUtils sharePreferenceUtils=new SharePreferenceUtils(context);
        extend.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                sharePreferenceUtils.putBoolean("iseva",true);
                sharePreferenceUtils.putString("isevatime", Utils.gettime(System.currentTimeMillis())+"");
            }
        });

        TextView settle = findViewById(R.id.settle);
        RatingBar rbar = findViewById(R.id.rbar);

        settle.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                xPopupCallback.onConfirm(rscore);
                sharePreferenceUtils.putBoolean("iseva",false);
                sharePreferenceUtils.putString("isevatime", "");
            }
        });

        rbar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                String rscores = String.valueOf(rating);
                rscore=rscores;

            }
        });

    }
    OnConfirmListener xPopupCallback;
    public BasePopupView setPopupCallback(OnConfirmListener xPopupCallback) {
        this.xPopupCallback = xPopupCallback;

        return this;
    }




    @Override
    protected int getMaxHeight() {
        return (int) (XPopupUtils.getScreenHeight(getContext()) * .7f);
    }
}